<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商品管理管理</title>
	<meta name="decorator" content="default"/>
	<link rel="stylesheet" type="text/css" href="${ctxStatic}/IDH/css/exhibition/checkbox.css" />
	<style>
	.chk:checked + label:after {
		content: '上架' !important;
	}
	.chk + label:after {
		content: '下架' !important;
	}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function shelve(id,status) {
			$.ajax({
				type:"POST",
				data:{id:id,status:status},
				async: false,
				url: "${ctx}/product/product/genProduct/shelve",
				dataType:"json",
				success:function(msg){
					 /* alert(msg.message);  */
				},
				error:function() {}
			});
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/product/product/genProduct/">商品管理列表</a></li>
		<shiro:hasPermission name="product:product:genProduct:edit"><li><a href="${ctx}/product/product/genProduct/form">商品管理添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="genProduct" action="${ctx}/product/product/genProduct/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>商品名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<%-- <li><label>状态：</label>
				<form:select path="status" cssStyle="width:285px;">
					<form:option value="">请选择</form:option>
					<form:option value="y">是</form:option>
					<form:option value="n">否</form:option>
				</form:select>
			</li> --%>
			<li><label>分类：</label>
				<form:input path="catalogName" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>上架状态：</label>
				<form:select path="status" cssStyle="width:285px;">
					<form:option value="">请选择</form:option>
					<form:option value="y">是</form:option>
					<form:option value="n">否</form:option>
				</form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>序号</th>
				<th>商品名称</th>
				<th>货号</th>
				<th>是否是推荐商品</th>
				<th>新品</th>
				<th>分类</th>
				<th>现价</th>
				<th>库存</th>
				<td>上架/下架</td>
				<shiro:hasPermission name="product:product:genProduct:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="genProduct" varStatus="ss">
			<tr>
				<td>${ss.index +1 }</td>
				<td><a href="${ctx}/product/product/genProduct/form?id=${genProduct.id}">
					${genProduct.name}
				</a></td>
				<td>${genProduct.code}</td>
				<td>${genProduct.isrecommend == 'y' ? '是':'否'}</td>
				<td>${genProduct.isnew == 'y' ? '是':'否'}</td>
				<td>${genProduct.catalogName}</td>
				<td>${genProduct.nowprice}</td>
				<td>${genProduct.stock}</td>
				<td>
					<c:if test="${genProduct.status == 'y'}">
						<input type="checkbox" id="${genProduct.id}"  class="chk" checked/><label onclick="shelve('${genProduct.id}','n');" for="${genProduct.id}"></label>
					</c:if>
					<c:if test="${genProduct.status == 'n'}">
						<input type="checkbox" id="${genProduct.id}"  class="chk"/><label onclick="shelve('${genProduct.id}','y');" for="${genProduct.id}"></label>
					</c:if>
				</td>
				<shiro:hasPermission name="product:product:genProduct:edit"><td>
    				<a href="${ctx}/product/product/genProduct/form?id=${genProduct.id}">修改</a>
					<a href="${ctx}/product/product/genProduct/delete?id=${genProduct.id}" onclick="return confirmx('确认要删除  ${genProduct.name} 吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>